#获取需求文件
import json
from flask import request
from db_client import *

def get_demand_file():
        id = request.args.get('id')
        t = {}
        results = mysql_client.get_demand_file(id)
        for result in results:
                t = {
                        "id" : result[0],
                        "content" : result[1],
                        "date" : result[2]
                }
        data = {
                "demand_files" : t
        }
        return json.dumps(data,ensure_ascii=False)

def get_demand_files():
        id = request.args.get('id')
        data = []
        results = mysql_client.get_demand_files()
        for result in results:
                t = {
                        "id" : result[0],
                        "content" : result[1],
                        "date" : result[2]
                }
                data.append(t)
        return json.dumps(data,ensure_ascii=False)
